package com.example.yls.demoa;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

    private ListView lvStudent;
    private Button btnAdd;
    private Button btnSearch;
    private ArrayList<Student> studentArrayList = new ArrayList<>();
    private StudentAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        lvStudent = findViewById(R.id.lv_stu);
        btnAdd = findViewById(R.id.btn_add);
        btnSearch = findViewById(R.id.btn_sreach);

        adapter = new StudentAdapter(MainActivity.this,studentArrayList);
        lvStudent.setAdapter(adapter);
       /* studentArrayList.add(new Student("1008","方凯彬",45));
        studentArrayList.add(new Student("1008","方凯彬",45));
        studentArrayList.add(new Student("1008","方凯彬",45));*/
        btnAdd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,AddActivity.class);
               startActivityForResult(intent,1001);
            }
        });

    }
}
